package cn.lxh.auto_configure;

import cn.lxh.properties.TencentMapProperties;
import cn.lxh.template.MapTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

/**
 * @author lxh Create Time: 2023/12/26 23:38
 * 自动配置类
 */
@Configuration
@EnableConfigurationProperties(TencentMapProperties.class)
public class MapConfiguration {

    @Bean
    @ConditionalOnMissingBean // 不存在这个bean才创建, 存在就不创建
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }

    @Bean
    public MapTemplate mapTemplate(TencentMapProperties tencentMapProperties, RestTemplate restTemplate){
        return new MapTemplate(tencentMapProperties, restTemplate);
    }
}
